package ru.tennisworld.match.utils;

import lombok.Getter;
import lombok.Setter;
import ru.tennisworld.match.data.enums.ValidationErrorEnum;

import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class ValidationResult {

    private Map<ValidationErrorEnum, String> errorsList = new HashMap<>();

    public void addError(ValidationErrorEnum error) { addError(error, error.getDefaultMessage()); }

    public void addError(ValidationErrorEnum error, String message) {
        this.errorsList.put(error, message);
    }

    public void mergeValidation(ValidationResult validationResult) {
        if (validationResult != null && validationResult.getErrorsList() != null && !validationResult.getErrorsList().isEmpty()) {
            this.errorsList.putAll(validationResult.getErrorsList());
        }
    }

    public boolean isValidationError() { return !this.errorsList.isEmpty(); }
}
